package org.example.batchutils.controller;

import org.example.batchutils.pojo.Result;
import org.example.batchutils.service.ExcelImportDatasource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/excel")
public class ExcelImportController {

    @Autowired
    private ExcelImportDatasource excelImportService;

    @RequestMapping("/Datasource")
    public Result getAllPollName() {
        return Result.success(excelImportService.getAllPollName());
    }

    @PostMapping("/import")
    public Result importData(@RequestParam("file") MultipartFile file,@RequestParam("poolName") String poolName) {
        return excelImportService.importData(file, poolName);
    }

}
